
package GUILayer;

import java.util.ArrayList;

import javax.swing.table.DefaultTableModel;
import ModelLayer.Ordre;
import ModelLayer.Lager;
public class OrdreModel extends DefaultTableModel {
        /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		private ArrayList<Ordre> ordre;

        public OrdreModel()
        {
            ordre = new ArrayList<Ordre>();
            
        }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }

    
        
    public void setData(ArrayList<Ordre> ordre)
    {
        this.ordre = ordre;
        fireTableDataChanged();
    }

    public ArrayList<Ordre> getOrdre() {
        return ordre;
    }
    
    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public int getRowCount() 
    {
    	
        if(ordre == null)
        {
            return 0;
        }
        else
        {
            return ordre.size();
        }
    }

    @Override
    public String getColumnName(int column) {
        String columnName = "";
        switch(column)
        {
            case 0:
            columnName = "KundeID";
            break;  
            case 1:
            columnName = "OrdreId";
            break;   
            case 2:
            columnName = "OrdreStatus";
        }        
        return columnName;
    }
    
    

    @Override
    public Object getValueAt(int row, int column) 
    {
        Object value = null;
        switch(column)
        {
            case 0:
                value = ordre.get(row).getKundeId().getKundeID();
                break;
            case 1:
            	value = ordre.get(row).getOrderId();
                break;
            case 2:
            	value = ordre.get(row).getOrdreStatus();
                break;
           
        }
                
        return value;
    }
        
}